<template>
  <div class="container">
    <normal-title
      title='订单详情'
      :back="true"
    ></normal-title>
    <div
      class="main"
      v-if="orderInfo!==null&&orderInfo.userCoupon"
    >
      <div
        class="card"
        v-for="(item, index) in orderInfo.orderProduct"
        :key="index"
      >
        <img
          class="thumb"
          :src="item.image"
          mode="aspectFit"
        >
        <div class="info">
          <p class="text">{{item.product_name}}</p>
          <div class="spec">规格: {{item.item_no}}</div>
          <div class="row">
            <p class="price"><span class="price-icon">￥</span>{{item.price}}</p>
            <div class="count">X {{item.num}}</div>
          </div>
        </div>
      </div>
      <div class="row between">
        <div class="item-name">优惠券码</div>
        <div class="order-val">{{orderInfo.userCoupon[0].code}}</div>
      </div>
      <div class="row between">
        <div class="item-name">优惠券名称</div>
        <div class="order-val">{{orderInfo.userCoupon[0].title}}</div>
      </div>
      <div class="row between">
        <div class="item-name">下单用户</div>
        <div class="order-val">{{orderInfo.userCoupon[0].nickname}}</div>
      </div>
      <div class="row between">
        <div class="item-name">商品总额</div>
        <div class="item-val price"> ¥{{orderInfo.payment}}</div>
      </div>
      <div class="row between">
        <div class="item-name">订单编号</div>
        <div class="order-val">{{orderInfo.order_no}}<span
            @click="copyOrderNum"
            class="copy"
          >复制</span></div>
      </div>
      <!-- <div class="row end-item">
        <div class="btn">删除</div>
      </div> -->
    </div>
    <div
      class="express"
      v-if="expressInfo!==null"
    >
      <div
        class="session"
        style="padding:30rpx 30rpx 0 30rpx"
      >
        <div class="item-name">物流信息：{{orderInfo.express}}</div>
        <div class="express-no">运单号：{{orderInfo.express_no}}</div>
        <div class="line"></div>
        <div
          class="row"
          v-for="(item,index) in expressInfo.data"
          :key="index"
        >
          <div class="col">
            <!-- <img
              class="exp-icon"
              src="../../images/exp-finish.png"
              mode="aspectFit"
            > -->
            <div class="dot"></div>
            <div
              v-if="index!=expressInfo.data.length-1"
              class="col-line"
            ></div>
          </div>
          <div class="exp-detail">
            <div class="exp-info">{{item.status}}</div>
            <div class="date">{{item.time}}</div>
          </div>
        </div>

      </div>
    </div>
    <bottom-btn />
  </div>
</template>

<script>
import NormalTitle from "@/components/NormalTitle";
import BottomBtn from "@/components/BottomBtn";
import ProductCard from "@/components/ProductCard";
import { request } from "@/utils";
export default {
  components: {
    NormalTitle,
    ProductCard,
    BottomBtn
  },
  computed: {},
  data() {
    return {
      orderInfo: null,
      expressInfo: null,
      discount: 0
    };
  },
  methods: {
    async getOrderInfo() {
      var order_id = this.$root.$mp.query.order_id;
      var openid = this.$root.$mp.query.openid;
      var res = await request("/v1/order/" + order_id, "get", { openid });
      this.orderInfo = res.data;
      if (this.orderInfo.express_no) {
        var res = await request("/v1/order/express-search", "get", {
          express_no: this.orderInfo.express_no
        });
        this.expressInfo = res.data;
      }
    },
    copyOrderNum() {
      wx.setClipboardData({
        data: this.orderInfo.order_no
      });
    }
  },
  onShow() {
    this.getOrderInfo();
  }
};
</script>

<style>
page {
  height: 100%;
}
</style>

<style scoped lang="scss">
.container {
  font-size: 26rpx;
  color: #6d6d6d;
  .main {
    padding: 0 25rpx;
    .card {
      .row {
        margin: 0;
      }
      font-size: 26rpx;
      display: flex;
      align-items: center;
      justify-content: flex-start;
      height: 200rpx;
      border-bottom: 1rpx solid #f0f0f0;
      .thumb {
        width: 160rpx;
        height: 160rpx;
        border-radius: 15rpx;
        margin-right: 30rpx;
      }
      .info {
        width: 460rpx;
        height: 160rpx;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        // border: 1rpx solid #000;
        .spec {
          font-size: 20rpx;
          color: #747474;
          margin-bottom: 5rpx;
          overflow: hidden;
          text-overflow: ellipsis;
          position: relative;
          bottom: 10rpx;
        }
        .text {
          overflow: hidden;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-line-clamp: 2;
          -webkit-box-orient: vertical;
          height: 75rpx;
          font-size: 600;
          color: #000;
        }
        .row {
          display: flex;
          justify-content: space-between;
          align-items: flex-end;
          height: 35rpx;
          line-height: 26rpx;
          .price {
            color: #b93a39;
            font-size: 36rpx;
            font-weight: 400;
            .price-icon {
              font-size: 24rpx;
              display: inline-block;
            }
          }
          .count {
            font-size: 20rpx;
          }
        }
      }
    }
    .row {
      margin: 50rpx 0;
    }
    .item-name {
      font-size: 32rpx;
      font-weight: 500;
      color: #000;
    }
    .price {
      color: #b93a39;
      font-weight: 600;
      font-size: 30rpx;
    }
    .order-val {
      font-size: 30rpx;
      .copy {
        color: #d9c59d;
        display: inline-block;
        margin-left: 30rpx;
        text-decoration: underline;
      }
    }
    .btn {
      color: #d9c59d;
      border-radius: 30rpx;
      border: 1rpx solid #d9c59d;
      height: 55rpx;
      line-height: 51rpx;
      text-align: center;
      width: 150rpx;
      font-size: 30rpx;
    }
  }
  .express {
    background: #f0f0f0;
    color: #747474;
    padding: 25rpx;
    font-size: 26rpx;
    .session {
      padding: 30rpx;
      margin-bottom: 30rpx;
      background: #fff;
      border-radius: 20rpx;
      .item-name {
        font-size: 34rpx;
        font-weight: 500;
        color: #000;
      }
      .express-no {
        color: #d5c095;
        font-size: 26rpx;
        margin-top: 10rpx;
      }
      .line {
        height: 3rpx;
        margin: 15rpx 0 30rpx;
        background: #f6f6f6;
      }
      .row {
        align-items: flex-start;
        position: relative;
      }
      .col {
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        align-items: center;
        position: absolute;
        width: 40rpx;
        .exp-icon {
          width: 40rpx;
          height: 40rpx;
        }
        .dot {
          width: 15rpx;
          height: 15rpx;
          background: #c9c9c9;
          border-radius: 50%;
        }
        .col-line {
          width: 5rpx;
          height: 100%;
          background: #ebebeb;
        }
      }
      .exp-detail {
        margin: -10rpx 0 45rpx 60rpx;
        .date {
          font-size: 20rpx;
        }
      }
    }
  }
}
</style>




